<template>
  <div>
    <TypeNav />
    <ListContainer />
    <TodayRecommend />
    <Rank />
    <Like />
    <Floor v-for="(item) in floorInfoList" :key="item.id" :floorInfo="item" />
    <Brand />
  </div>
</template>

<script>
import ListContainer from "./ListContainer/index.vue";
import TodayRecommend from "./TodayRecommend/index.vue";
import Rank from "./Rank/index.vue";
import Like from "./Like/index.vue";
import Floor from "./Floor/index.vue";
import Brand from "./Brand/index.vue";
import {mapState} from 'vuex';

export default {
  name: "Home",
  components: {
    ListContainer,
    TodayRecommend,
    Rank,
    Like,
    Floor,
    Brand,
  },
 //此处发送请求获取主页三级联动栏的数据移送到App组件中,避免每次回首页都会发送请求
 //优化方式之一

 //派发dispatch方法,获取floor需要的数据,并根据数据决定floor组件需要多少
 mounted() {
   this.$store.dispatch('getFloorInfo')
 },
 computed: {
   ...mapState({
     floorInfoList:(state) => state.home.floorInfoList
   })
 },
};
</script>

<style scoped lang="less">
</style>